package com.qianfeng.xiaxk.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.LinearLayout;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.qianfeng.xiaxk.R;
import com.qianfeng.xiaxk.utils.SplashUtils;

@ContentView(R.layout.activity_splash_layout)
public class SplashActivity extends AppCompatActivity {

    @ViewInject(R.id.loadingimage)
    LinearLayout loadingimage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ViewUtils.inject(this);
        AlphaAnimation alphaAnimation = new AlphaAnimation(0.4f, 1.0f);////透明都变化值
        alphaAnimation.setDuration(2000);////动画持续时间
        alphaAnimation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }
            @Override
            public void onAnimationEnd(Animation animation) {
                boolean isFirstFlag = SplashUtils.isFirst(SplashActivity.this);
                Log.e("",""+isFirstFlag);
                if(isFirstFlag){////第一次启动
                    SplashActivity.this.startActivity(new Intent(SplashActivity.this,GuideActivity.class));
                }else{
                    SplashActivity.this.startActivity(new Intent(SplashActivity.this,MainActivity.class));
                }
                SplashActivity.this.finish();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        loadingimage.startAnimation(alphaAnimation);
    }


}
